package std.game.objects.exits


/**
 * Copyright 2008 Matthew Corby-Eaglen
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
import org.groovymud.object.registry.Registry;

import org.groovymud.object.Container;
import org.groovymud.object.MudObject;
import org.easymock.classextension.MockClassControl
import org.groovymud.object.registry.MudObjectAttendant;
import org.groovymud.object.room.Room
import org.easymock.MockControl
import org.groovymud.engine.event.messages.MessageEvent
import org.groovymud.object.room.Exit
import org.groovymud.shell.command.CommandInterpreter
import org.groovymud.object.alive.Alive
import org.groovymud.engine.event.EventScope
import org.groovymud.engine.event.observer.Observable
import std.game.objects.alive.MOBImpl
import std.game.objects.containers.RoomImpl
import org.groovymud.object.ObjectLocation
import org.groovymud.engine.event.system.MovementEvent
import std.game.objects.exits.events.ArrivalEvent
/**
 * @author corbym
 *
 */
public class ExitImplTest extends GroovyTestCase{
	
	
	
	
	/* (non-Javadoc)
	 * @see std.game.objects.exits.ExitImpl#go(org.groovymud.object.alive.Alive)
	 */
	final void testGo(){
		//TODO Implement the Testmethod Go
		def mob
		boolean called = false
		ObjectLocation loc = new ObjectLocation()
		MudObjectAttendant attendant = new MudObjectAttendant(null){
					public void moveToLocation(MudObject player, ObjectLocation location) {
						assert mob == player
						assert location == loc
					}
				}
		def cont = [getExit : {String dir ->
			assert dir == "east"
			return new ExitImpl(direction : "east")
		}
		] as Room
		
		Registry reg = new Registry(null){
			public MudObjectAttendant getMudObjectAttendant() {attendant};
		}
		def exit = new ExitImpl(direction: "west", arrivalDirection: "east", destination: loc, registry: reg)
				
		mob = [getName: "foo", fireEvent: { event ->  called = true },
		getCurrentContainer : {  cont },
		getDepartureMessage : { obj ->
			assert obj == exit 
		},
		getArrivalMessage : { obj -> 
			assert obj.direction == "east"
		},
		look : { called = true;}
		] as MOBImpl
		
		
		
		exit.go mob, "west"
		assertTrue called
	}
	
	
}
